package com.tidc.seaserverweb.controller;

import com.tidc.seaservermodel.aspect.WebLog;
import com.tidc.seaservermodel.entity.Fres;
import com.tidc.seaservermodel.entity.Shop;
import com.tidc.seaservermodel.exception.TidcAuthorityException;
import com.tidc.seaservermodel.exception.TidcBadParent;
import com.tidc.seaserverservice.service.SupervisorShopService;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.Authentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.sql.SQLException;
import java.util.Map;


@RestController
@RequestMapping("/supervisor/shop")
public class SupervisorShopController {
    @Resource
    private SupervisorShopService supervisorShopService;
    @PostMapping("/commodity")
    public Fres<String> addCommodity(@RequestBody @Validated Shop shop, Authentication authentication) throws SQLException {
        return supervisorShopService.addCommodity(shop, authentication);
    }
    @GetMapping("/list")
    public Fres<Map<Object,Object>> getShopList(@Param("query") String query,@RequestParam("pageSize") int pageSize, @RequestParam("pageNum") int pageNum,Authentication authentication) throws TidcBadParent {
        return supervisorShopService.getShopList(query,pageSize,pageNum,authentication);
    }
    @WebLog(description = "修改奖励")
    @PutMapping("/commodity")
    public Fres<String> updateIsShow(@RequestBody Shop shop,Authentication authentication) throws SQLException, TidcBadParent {
        return supervisorShopService.updateIsShow(shop,authentication);
    }
    @GetMapping("/id")
    public Fres<Shop> getShopById(@Param("id")int id,Authentication authentication){
        return supervisorShopService.getShopById(id,authentication);
    }
}
